package cpgears.helpers {
	import asunit.framework.TestCase;
	
	/**
	 * ...
	 * @author Whyves
	 */
	public class StringUtilTest extends TestCase{
		
		public function StringUtilTest(testMethod:String = null) {
			super(testMethod);
		}

		public function testFormatNoTokens():void {
			var formattedMessage:String = StringUtil.format("Formatted message");
			assertEquals("Formatted message", formattedMessage);
		}
		
		public function testFormatMissingToken():void {
			var formattedMessage:String = StringUtil.format("Formatted message {0}");
			assertEquals("Formatted message {0}", formattedMessage);
		}

		public function testFormatOneToken():void {
			var formattedMessage:String = StringUtil.format("Formatted message {0}", "#1");
			assertEquals("Formatted message #1", formattedMessage);
		}

		public function testFormatManyToken():void {
			var formattedMessage:String = StringUtil.format("Formatted message {0}, {1}, {2}", "#1", "#2", "#3");
			assertEquals("Formatted message #1, #2, #3", formattedMessage);
		}

		public function testFormatManyTokenAsArrayInFirstToken():void {
			var formattedMessage:String = StringUtil.format("Formatted message {0}, {1}, {2}", ["#1", "#2", "#3"]);
			assertEquals("Formatted message #1, #2, #3", formattedMessage);
		}
		
		public function testStringNullEmptyWithNull():void {
			assertTrue(StringUtil.isNullOrEmpty(null));
		}

		public function testStringNullEmptyWithEmpty():void {
			assertTrue(StringUtil.isNullOrEmpty(""));
		}
		
		public function testStringNullEmptyWithString():void {
			assertFalse(StringUtil.isNullOrEmpty("qwe"));
		}
	}
}